<section class="section {page->class}">
	<h2 class="hide">{page->title}</h2>
	<script>
		$(function() {
			$("#anniversary_add").validate({
				submitHandler : function(form) {
					// ajax로 등록후 list 페이지 새로 고침
					$.ajax({
						 url : form.action
						,data : $(form).serialize()
						,success:function(data){
							if(data.code == mesg.success) {
								sagapo.article_refresh(data.return_url);
								
								// 리스트 페이지에서 변경된 값 바꿔주기
								$(".name_{result->ay_seq}").text($("#{module}_name").val());
								$(".date_{result->ay_seq}").text($("#{module}_day").val());
								
								
								// 양, 음력 변환
								var solar = $("#anniversary_add input[name='{module}_is_solar']:checked");
								var solar_class = "solar";
								var solar_text = $(solar).next('label').text();
								if($(solar).val() == "0") {
									solar_class = "lunar";
								}
								$(".solar_{result->ay_seq}").attr("class", "solar_{result->ay_seq} "+solar_class).text("("+solar_text+")");
								
								// 메인 표시 여부.
								var anniversary_name = $(".name_{result->ay_seq}");
								
								if($("#{module}_main:checked").length > 0) {
									if(!$(anniversary_name).hasClass("main")) {
										$(anniversary_name).addClass("main");
									}
								} else {
									if($(anniversary_name).hasClass("main")) {
										$(anniversary_name).removeClass("main");
									}
								}
							} else {
								alert(data.msg);
							}
							
							return false;
						}
					});
				}	
			});
			
			$( "#{module}_day" ).datepicker();
			
			// checkbox, radio 선택..
			$("input:radio[name='{module}_is_solar'][value='{result->ay_is_solar}']").attr("checked","checked");
			$("input:radio[name='{module}_display'][value='{result->ay_display}']").attr("checked","checked");
			$("input:checkbox[name='{module}_main'][value='{result->ay_main}']").attr("checked","checked");
		});
	</script>
	<form name="anniversary_add" id="anniversary_add" method="post" action="{action}/doModify">
		<input type="hidden" name="seq" value="{result->ay_seq}" />
		<table class="table">
			<caption>
				{page->title}
			</caption>
			<colgroup>
				<col class="add" />
				<col />
			</colgroup>
			<tbody>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_name">기념일 명</label></th>
					<td><input type="text" name="{module}_name" id="{module}_name" class="{module}_name required width_90" placeholder="기념일 명" value="{result->ay_name}" /></td>
				</tr>
				<tr class="odd">
					<th scope="row" class="txt_right br"><label for="{module}_solar">양/음력</label></th>
					<td>
						<input type="radio" name="{module}_is_solar" id="{module}_solar" value="1" checked="checked" />
						<label for="{module}_solar">양력</label>
						<input type="radio" name="{module}_is_solar" id="{module}_lunar" value="0" />
						<label for="{module}_lunar">음력</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_day">기념일</label></th>
					<td><input type="text" name="{module}_day" id="{module}_day" class="{module}_day" placeholder="기념일" value="{result->date}" /></td>
				</tr>
				<tr class="odd">
					<th scope="row" class="txt_right br"><label for="{module}_d_day">계산방법</label></th>
					<td>
						<input type="radio" name="{module}_display" id="{module}_d_day" value="0" checked="checked" />
						<label for="{module}_d_day">d_day</label>
						<input type="radio" name="{module}_display" id="{module}_days" value="1" />
						<label for="{module}_days">날짜수</label>
						<input type="radio" name="{module}_display" id="{module}_repeat" value="2" />
						<label for="{module}_repeat">반복</label>
					</td>
				</tr>
				<tr>
					<th scope="row" class="txt_right br"><label for="{module}_main">메인표시</label></th>
					<td>
						<input type="checkbox" name="{module}_main" id="{module}_main" value="1" />
						<label for="{module}_main">메인표시</label>
					</td>
				</tr>
			</tbody>
		</table>
		<div class="button_area">
			<button type="submit">전송</button>
		</div>
	</form>
</section>